//
//  main.m
//  OC6_字典&数组作业练习
//
//  Created by dllo on 15/10/30.
//  Copyright (c) 2015年 dllo. All rights reserved.
//

#import <Foundation/Foundation.h>
#import "Contact.h"
#import "ContactManager.h"


int main(int argc, const char * argv[]) {

    Contact *c1 = [[Contact alloc] initWithName:@"Djjj" sex:@"male" phonenum:@"1333333" address:@"西山" group:@"同学" age:22];
    Contact *c2 = [[Contact alloc] initWithName:@"Cjjj" sex:@"female" phonenum:@"1444444" address:@"马兰" group:@"朋友" age:55];
    Contact *c3 = [[Contact alloc] initWithName:@"Phhh" sex:@"male" phonenum:@"1444444" address:@"春柳" group:@"家人" age:44];
    Contact *c4 = [[Contact alloc] initWithName:@"Cyyy" sex:@"female" phonenum:@"1555555" address:@"南沙" group:@"同学" age:33];
    
    ContactManager *contactList = [[ContactManager alloc] init];
    [contactList addPerson:c1];
    [contactList addPerson:c2];
    [contactList addPerson:c3];
    [contactList addPerson:c4];
    
    // 4, 获取某个分组名称下所有联系人,并且按照姓名升序排列
//    NSMutableArray *arr = [NSMutableArray array];
//    arr = [contactList sortByGroup:@"同学"];
//    for (Contact *contact in arr) {
//        NSLog(@"%@ %@ %@ %@ %@ %ld", [contact name], [contact sex], [contact phonenum], [contact address], [contact group], [contact age]);
//    }
    
    // 5,从通讯录中根据电话号码搜索联系人。
//    NSMutableArray *arr = [contactList searchByPhone:@"1444444"];
//    for (NSInteger i = 0; i < arr.count; i++) {
//        NSLog(@"%@ %@ %@ %@ %@ %ld", [[arr objectAtIndex:i] name], [[arr objectAtIndex:i] sex], [[arr objectAtIndex:i] phonenum], [[arr objectAtIndex:i] address], [[arr objectAtIndex:i] group], [[arr objectAtIndex:i] age]);
//    }
    
    // 6,获取所有女性的联系人，并且按照年龄的降序排列。
//    NSMutableArray *arr = [contactList sortByAge:@"female"];
//    for (Contact *contact in arr) {
//        NSLog(@"%@ %@ %@ %@ %@ %ld", [contact name],[contact sex], [contact phonenum], [contact address], [contact group], [contact age]);
//    }
    
//   7, 根据姓名删除某个联系人。
    
//    [contactList deleteByName:@"Cjjj"];
    
//   8, 删除某个分组的全部联系人。
    
//    [contactList deleteByGroup:@"同学"];
    
    
    
    [contactList infoAllContact];
    
    
    
    
    
    
    
    
    return 0;
}
